package com.libre.config;


import javafx.fxml.FXMLLoader;
import javafx.scene.layout.AnchorPane;
import org.springframework.core.io.ResourceLoader;

import java.io.IOException;
import java.net.URL;
import java.util.Locale;
import java.util.ResourceBundle;

/**
 *@Description 国际化
 *@Author 庞留杰
 *@Date2022/5/19 12:37
 *@Version V1.0
 **/
public class MyLocaleResolver {

    public void initLocale(AnchorPane pane) throws IOException {
        Locale locale = Locale.getDefault();
        System.out.println("locale = " + locale);
        FXMLLoader fxmlLoader = new FXMLLoader();
        URL url = fxmlLoader.getClassLoader().getResource("static/fxml/test.fxml");//%+变量
        fxmlLoader.setLocation(url);
        ResourceBundle resourceBundle = ResourceBundle.getBundle("i18n/language", Locale.CHINESE);
        fxmlLoader.setResources(resourceBundle);
        pane = fxmlLoader.load();
    }

}
